package com.repair.miniApp.controller;

import com.repair.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.repair.common.core.controller.BaseController;
import com.repair.common.core.domain.AjaxResult;
import com.repair.miniApp.domain.RepairOrder;
import com.repair.miniApp.service.RepairOrderService;

import java.util.List;

/**
 * 维修订单Controller
 *
 * @author repair
 * @date 2024-12-10
 */
@Anonymous
@RestController
@RequestMapping("/api/repair-orders")
public class RepairOrderController extends BaseController
{
    @Autowired
    private RepairOrderService repairOrderService;

    /**
     * 新增维修订单
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody RepairOrder repairOrder)
    {
        repairOrderService.insertRepairOrder(repairOrder);
        return AjaxResult.success(repairOrder);
    }

    /**
     * 查询维修订单列表
     */

    @GetMapping("/list")
    public AjaxResult list()
    {
        List<RepairOrder> repairOrder = repairOrderService.selectRepairOrderList();
        return AjaxResult.success(repairOrder);
    }

    /**
     * 更新维修订单的开始处理信息、图片和状态
     */
    @PostMapping("/updateStartInfo")
    public AjaxResult updateStartInfo(@RequestBody RepairOrder repairOrder) {
        repairOrderService.updateStartInfo(repairOrder);
        return AjaxResult.success(repairOrder);
    }

    /**
     * 更新维修订单的完成处理信息、图片和状态
     */
    @PostMapping("/updateFinishInfo")
    public AjaxResult updateFinishInfo(@RequestBody RepairOrder repairOrder) {
        repairOrderService.updateFinishInfo(repairOrder);
        return AjaxResult.success(repairOrder);
    }

}
